package com.lnu.information.thread;

/**
 * @author : jian.zhang-2
 * @description:
 * @date : Create in 3:37 PM 2022/5/12
 * @modified By :
 */
public class Tickets {
    private int num = 50;

    public synchronized int getNum() {
        return num;
    }

    public void setNum(int num) {
        this.num = num;
    }

    public synchronized void saleTicket(){
        if(num > 0){
            System.out.println(Thread.currentThread() + ":NO." + num + " ticket is sailed");
            try {
                Thread.sleep(5);
            }catch (InterruptedException e){
                e.printStackTrace();
            }
            num--;
        }
    }
}
